package Simulate;

import Data.Data;
import Grid.Grid;
import Grid.Map;

//simulation contains main it enables to run grid for see a simulation of the flu

public class Simulation {

    private static Grid g;

    public static void main(String[] arguments) throws InterruptedException {

        int[] args = new int[arguments.length];
        for (int i = 0; i < args.length; i++) {
            args[i] = Integer.parseInt(arguments[i]);
        }

        if (args.length == 4) {
            Data.nHuman = args[0];
            Data.nChicken = args[1];
            Data.nDuck = args[2];
            Data.nPig = args[3];
        } else if (args.length == 7) {
            Data.nHuman = args[0];
            Data.nChicken = args[1];
            Data.nDuck = args[2];
            Data.nPig = args[3];
            Data.nChickenSick = args[4];
            Data.nDuckSick = args[5];
            Data.nPigSick = args[6];
        } else if (args.length == 8) {
            Data.nHuman = args[0];
            Data.nChicken = args[1];
            Data.nDuck = args[2];
            Data.nPig = args[3];
            Data.nChickenSick = args[4];
            Data.nDuckSick = args[5];
            Data.nPigSick = args[6];
            Data.dayTime = args[7];
        } else {
            System.out.println("Default value kept");
        }

        System.out.println("number of human : " + Data.nHuman);
        System.out.println("number of chicken : " + Data.nChicken + " with "
                + Data.nChickenSick + " of them sick");
        System.out.println("number of duck : " + Data.nDuck + " with "
                + Data.nDuckSick + " of them sick");
        System.out.println("number of pig : " + Data.nPig + " with "
                + Data.nPigSick + " of them sick \n");

        Thread.sleep(Data.informationTime);

        g = new Grid(Data.nElement,Data.nElementSick);

        Map map = new Map(g);

        boolean test = true;
        while (test) {

            System.out.println("Day " + Data.time);

            System.out.println(map + "\n\n");
            Thread.sleep(Data.dayTime);
            test = g.nextDay();
            map.setGrid(g);
            Data.time++;
        }
    }

}
